package csdn;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 项目名称：wangxu
 * 类 名 称：获得完美走位
 * 描 述：https://dream.blog.csdn.net/article/details/129488158
 * 创建时间：2023/4/13 07:25 下午
 * 创 建 人：wang-xu
 */
public class RealTopic11 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        try {
            String s = in.nextLine();
            if (s.length() < 1 || s.length() > 10*10*10*10*10){
                System.out.println("input error");
            }
            if (s.length()%4 !=0){
                System.out.println("input error");
            }
            if (!s.contains("A") || !s.contains("W") || !s.contains("S")|| !s.contains("D")){
                System.out.println("No A B C D");
            }

            char[] chars = s.toCharArray();
            // map用于记录ABCD出现的次数
            Map<Character, Integer> map = new HashMap<>();
            int a = counts('A',chars);
            int b = counts('W',chars);
            int c = counts('S',chars);
            int d= counts('D',chars);
            map.put('A',a);
            map.put('W',b);
            map.put('S',c);
            map.put('D',d);

            // 判断完美走位条件
            int all = a+b+c+d;
            if (all < s.length()){
                System.out.println("has other words");
                return;
            }
            int avg = s.length()/4;
            if (all == s.length()){
                if (a==b && a == c && a == d){
                    System.out.println(0);
                }else {

                }

            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static int counts(char s,char[] chars){
        int counts = 0;
        for (char c:chars) {
            if (s == c){
                counts++;
            }
        }
        return counts;
    }


    public static int minusValue(int a,int avg){
        int minusValue = 0;
        if (a >= avg){
            minusValue = a -avg;
        }else {
            minusValue = avg - a;
        }
        return minusValue;
    }
}
